<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>数据管理员</title>

		<meta name="keywords" content="Bootstrap模版,Bootstrap模版下载,Bootstrap教程,Bootstrap中文" />
		<meta name="description" content="站长素材提供Bootstrap模版,Bootstrap教程,Bootstrap中文翻译等相关Bootstrap插件下载" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />

		<!-- basic styles -->

		<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="assets/css/font-awesome.min.css" />

		<!--[if IE 7]>
		  <link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css" />
		<![endif]-->

		<!-- page specific plugin styles -->

		<link rel="stylesheet" href="assets/css/jquery-ui-1.10.3.full.min.css" />
		<link rel="stylesheet" href="assets/css/datepicker.css" />
		<link rel="stylesheet" href="assets/css/ui.jqgrid.css" />

		<!-- fonts -->

		<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,300" />

		<!-- ace styles -->

		<link rel="stylesheet" href="assets/css/ace.min.css" />
		<link rel="stylesheet" href="assets/css/ace-rtl.min.css" />
		<link rel="stylesheet" href="assets/css/ace-skins.min.css" />

		<!--[if lte IE 8]>
		  <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
		<![endif]-->

		<!-- inline styles related to this page -->

		<!-- ace settings handler -->

		<script src="assets/js/ace-extra.min.js"></script>

		<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

		<!--[if lt IE 9]>
		<script src="assets/js/html5shiv.js"></script>
		<script src="assets/js/respond.min.js"></script>
		<![endif]-->
	</head>

	<body>
		<div class="navbar navbar-default" id="navbar">
			<script type="text/javascript">
				try{ace.settings.check('navbar' , 'fixed')}catch(e){}
			</script>

			<div class="navbar-container" id="navbar-container">
				<div class="navbar-header pull-left">
					<a href="publicdataaministrator.jsp" class="navbar-brand">
						<small>
							<i class="icon-leaf"></i>
							面向研究团队的参考文献管理与服务系统
						</small>
					</a><!-- /.brand -->
				</div><!-- /.navbar-header -->

				<div class="navbar-header pull-right" role="navigation">
					<ul class="nav ace-nav">
						<li class="light-blue">
							<a data-toggle="dropdown" href="#" class="dropdown-toggle">
								<img class="nav-user-photo" src="assets/avatars/user.png" alt="Jason's Photo" />
								<span class="user-info">
									<small>欢迎,</small>
									Admin
								</span>

								<i class="icon-caret-down"></i>
							</a>

							<ul class="user-menu pull-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
								<li>
									<a href="#">
										<i class="icon-cog"></i>
										设置
									</a>
								</li>

								<li>
									<a href="#">
										<i class="icon-user"></i>
										简介
									</a>
								</li>

								<li class="divider"></li>

								<li>
									<a href="index.jsp">
										<i class="icon-off"></i>
										退出
									</a>
								</li>
							</ul>
						</li>
					</ul><!-- /.ace-nav -->
				</div><!-- /.navbar-header -->
			</div><!-- /.container -->
		</div>
		
		

		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<div class="main-container-inner">
				<a class="menu-toggler" id="menu-toggler" href="#">
					<span class="menu-text"></span>
				</a>

				<div class="sidebar" id="sidebar">
					<script type="text/javascript">
						try{ace.settings.check('sidebar' , 'fixed')}catch(e){}
					</script>

					<div class="sidebar-shortcuts" id="sidebar-shortcuts">
						<div class="sidebar-shortcuts-large" id="sidebar-shortcuts-large" style="background-color:#33CCFF;">
							<span></span>数据管理员信息
						</div>
						<!--
						<div>
							<h5>数据管理员信息和职责介绍</h5>
							<p>（1）管理城市国家表单</p>						
							<p>（2）管理出版商信息表</p>
							<p>（3）管理机构表</p>					
						</div>
						-->
					</div><!-- #sidebar-shortcuts -->

					<ul class="nav nav-list">
						<li class="active open" class="active">
							<a href="#" class="dropdown-toggle">
								<i class="icon-list"></i>
								<span class="menu-text"> 表单管理</span>

								<b class="arrow icon-angle-down"></b>
							</a>

							<ul class="submenu">
								<li>
									<a href="citystatetable.jsp">
										<i class="icon-double-angle-right"></i>
										城市国家表
									</a>
								</li>

								<li>
									<a href="publishertable.jsp">
										<i class="icon-double-angle-right"></i>
										出版商信息表
									</a>
								</li>
								
								<li>
									<a href="internalpublishertable.jsp">
										<i class="icon-double-angle-right"></i>
										国内出版商信息表
									</a>
								</li>
								
								<li>
									<a href="institutiontable.jsp">
										<i class="icon-double-angle-right"></i>
										机构表
									</a>
								</li>
							</ul>
						</li>
					
					</ul><!-- /.nav-list -->

					<div class="sidebar-collapse" id="sidebar-collapse">
						<i class="icon-double-angle-left" data-icon1="icon-double-angle-left" data-icon2="icon-double-angle-right"></i>
					</div>

					<script type="text/javascript">
						try{ace.settings.check('sidebar' , 'collapsed')}catch(e){}
					</script>
					
					
				</div>

				<div class="main-content">
					<div class="breadcrumbs" id="breadcrumbs">
						<script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>

						<ul class="breadcrumb">
							<li>
								<i class="icon-home home-icon"></i>
								<a href="publicdataaministrator.jsp">主页</a>
							</li>

							<li>
								<a href="#">数据管理员</a>
							</li>
							<li class="active">公共数据管理</li>
						</ul><!-- .breadcrumb -->

						<!-- #nav-search -->
					</div>

					<div class="page-content">

						<div class="row">
							<div class="col-xs-12" style="overflow:auto;">
								<!-- PAGE CONTENT BEGINS -->

								<!--
								<div class="alert alert-info">
									<i class="icon-hand-right"></i>

									Please note that demo server is not configured to save the changes, therefore you may get an error message.
									
									<button class="close" data-dismiss="alert">
										<i class="icon-remove"></i>
									</button>
									
								</div>
								-->

								<!-- 添加表单 -->
								<table id="grid-table"></table>
								
							

								<div id="grid-pager"></div>
								
								<table>
									<c:forEach var="x" items="${citystates}" varStatus="status">
										<tr>
											<td>${x.CityID}</td>
											<td>${x.Region}</td>
										</tr>		
									</c:forEach>

								</table>

								<script type="text/javascript">
									var $path_base = "/";//this will be used in gritter alerts containing images
								</script>

								<!-- PAGE CONTENT ENDS -->
							</div><!-- /.col -->
						</div><!-- /.row -->
					</div><!-- /.page-content -->
				</div><!-- /.main-content -->

			</div><!-- /.main-container-inner -->

			
		</div><!-- /.main-container -->

		<!-- basic scripts -->

		<!--[if !IE]> -->

<!-- 		<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
 -->
		<!-- <![endif]-->

		<!--[if IE]>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<![endif]-->

		<!--[if !IE]> -->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->

		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>
		<script src="assets/js/bootstrap.min.js"></script>
		<script src="assets/js/typeahead-bs2.min.js"></script>

		<!-- page specific plugin scripts -->

		<script src="assets/js/date-time/bootstrap-datepicker.min.js"></script>
		<script src="assets/js/jqGrid/jquery.jqGrid.min.js"></script>
		<script src="assets/js/jqGrid/i18n/grid.locale-ch.js"></script>

		<!-- ace scripts -->

		<script src="assets/js/ace-elements.min.js"></script>
		<script src="assets/js/ace.min.js"></script>

		<!-- inline scripts related to this page -->

		<script type="text/javascript">
		var grid_data = [];
		$.ajax({
			cache : true, //异步
			type : "POST",//post 是向服务器端发出请求的类型
			url : "./index.do",//必需。请求地址
			dataType : "json", //可选。返回数据的类型。可以是：string或json、xml等类型。
			async : true,
			error : function(request) {
			},
			success : function(result) {
				if (result != null) {
					for(var i = 0 ; i < result.length;i++){
						var city ={
								CityID:result[i].cityID,
								Region:result[i].region,
								StateName2:result[i].stateName2,
								StateName1:result[i].stateName1,
								StateAbbr:result[i].stateAbbr,
								CityName2:result[i].cityName2,
								CityName1:result[i].cityName1,
								datetime:result[i].dateTime
						}
						grid_data.push(city)
					}
						jQuery(function($) {
							var grid_selector = "#grid-table";
							var pager_selector = "#grid-pager";
						
							jQuery(grid_selector).jqGrid({
								//direction: "rtl",
								data: grid_data,
								datatype: "local",
								height: 250,
								colNames:['城市序号','区域','中文省州名','英文省州名', '缩写','中文城市名','英文城市名','更新时间'],
								colModel:[
									
									{name:'CityID',index:'CityID', width:15, sorttype:"int", editable: true},
									{name:'Region',index:'Region', width:40,editable: true,editoptions:{size:"20",maxlength:"30"}},
									{name:'StateName2',index:'StateName2', width:50,editable: true,editoptions:{size:"20",maxlength:"30"}},
									{name:'StateName1',index:'StateName1', width:50,editable: true,editoptions:{size:"20",maxlength:"30"}},
									{name:'StateAbbr',index:'StateAbbr', width:20,editable: true,editoptions:{size:"20",maxlength:"30"}},
									{name:'CityName2',index:'CityName2', width:50,editable: true,editoptions:{size:"20",maxlength:"30"}},
									{name:'CityName1',index:'CityName1', width:50,editable: true,editoptions:{size:"20",maxlength:"30"}},
									{name:'datetime',index:'datetime',width:90, editable:true, sorttype:"date",unformat: pickDate}
								], 
						
								viewrecords:true,
								del:true,
								add:true,
								rowNum:10,
								rowList:[10,20,30],
								pager : pager_selector,
								altRows: true,
								//toppager: true,
								
								multiselect: true,
								//multikey: "ctrlKey",
						        multiboxonly: true,
						
								loadComplete : function() {
									var table = this;
									setTimeout(function(){
										styleCheckbox(table);
										
										updateActionIcons(table);
										updatePagerIcons(table);
										enableTooltips(table);
									}, 0);
								},
						
								editurl: $path_base+"/dummy.html",//nothing is saved
								caption: "城市国家表",
						
						
								autowidth: true
						
							});
						
							//enable search/filter toolbar
							//jQuery(grid_selector).jqGrid('filterToolbar',{defaultSearch:true,stringResult:true})
						
							//switch element when editing inline
							function aceSwitch( cellvalue, options, cell ) {
								setTimeout(function(){
									$(cell) .find('input[type=checkbox]')
											.wrap('<label class="inline" />')
										.addClass('ace ace-switch ace-switch-5')
										.after('<span class="lbl"></span>');
								}, 0);
							}
							//enable datepicker
							function pickDate( cellvalue, options, cell ) {
								setTimeout(function(){
									$(cell) .find('input[type=text]')
											.datepicker({format:'yyyy-mm-dd' , autoclose:true}); 
								}, 0);
							}
						
						
							//navButtons
							jQuery(grid_selector).jqGrid('navGrid',pager_selector,
								{ 	//navbar options
									edit: true,
									editicon : 'icon-pencil blue',
									add: true,
									addicon : 'icon-plus-sign purple',
									del: true,
									delicon : 'icon-trash red',
									search: true,
									searchicon : 'icon-search orange',
									refresh: true,
									refreshicon : 'icon-refresh green',
									view: true,
									viewicon : 'icon-zoom-in grey',
								},
								{
									//edit record form
									//closeAfterEdit: true,
									recreateForm: true,
									beforeShowForm : function(e) {
										var form = $(e[0]);
										form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
										style_edit_form(form);
									}
								},
								{
									//new record form
									closeAfterAdd: true,
									recreateForm: true,
									viewPagerButtons: false,
									beforeShowForm : function(e) {
										var form = $(e[0]);
										form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
										style_edit_form(form);
									}
								},
								{
									//delete record form
									recreateForm: true,
									beforeShowForm : function(e) {
										var form = $(e[0]);
										if(form.data('styled')) return false;
										
										form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
										style_delete_form(form);
										
										form.data('styled', true);
									},
									onClick : function(e) {
										alert(1);
									}
								},
								{
									//search form
									recreateForm: true,
									afterShowSearch: function(e){
										var form = $(e[0]);
										form.closest('.ui-jqdialog').find('.ui-jqdialog-title').wrap('<div class="widget-header" />')
										style_search_form(form);
									},
									afterRedraw: function(){
										style_search_filters($(this));
									}
									,
									multipleSearch: true,
									/**
									multipleGroup:true,
									showQuery: true
									*/
								},
								{
									//view record form
									recreateForm: true,
									beforeShowForm: function(e){
										var form = $(e[0]);
										form.closest('.ui-jqdialog').find('.ui-jqdialog-title').wrap('<div class="widget-header" />')
									}
								}
							)
						
						
							
							function style_edit_form(form) {
								//enable datepicker on "sdate" field and switches for "stock" field
								form.find('input[name=sdate]').datepicker({format:'yyyy-mm-dd' , autoclose:true})
									.end().find('input[name=stock]')
										  .addClass('ace ace-switch ace-switch-5').wrap('<label class="inline" />').after('<span class="lbl"></span>');
						
								//update buttons classes
								var buttons = form.next().find('.EditButton .fm-button');
								buttons.addClass('btn btn-sm').find('[class*="-icon"]').remove();//ui-icon, s-icon
								buttons.eq(0).addClass('btn-primary').prepend('<i class="icon-ok"></i>');
								buttons.eq(1).prepend('<i class="icon-remove"></i>')
								
								buttons = form.next().find('.navButton a');
								buttons.find('.ui-icon').remove();
								buttons.eq(0).append('<i class="icon-chevron-left"></i>');
								buttons.eq(1).append('<i class="icon-chevron-right"></i>');		
							}
						
							function style_delete_form(form) {
								var buttons = form.next().find('.EditButton .fm-button');
								buttons.addClass('btn btn-sm').find('[class*="-icon"]').remove();//ui-icon, s-icon
								buttons.eq(0).addClass('btn-danger').prepend('<i class="icon-trash"></i>');
								buttons.eq(1).prepend('<i class="icon-remove"></i>')
							}
							
							function style_search_filters(form) {
								form.find('.delete-rule').val('X');
								form.find('.add-rule').addClass('btn btn-xs btn-primary');
								form.find('.add-group').addClass('btn btn-xs btn-success');
								form.find('.delete-group').addClass('btn btn-xs btn-danger');
							}
							function style_search_form(form) {
								var dialog = form.closest('.ui-jqdialog');
								var buttons = dialog.find('.EditTable')
								buttons.find('.EditButton a[id*="_reset"]').addClass('btn btn-sm btn-info').find('.ui-icon').attr('class', 'icon-retweet');
								buttons.find('.EditButton a[id*="_query"]').addClass('btn btn-sm btn-inverse').find('.ui-icon').attr('class', 'icon-comment-alt');
								buttons.find('.EditButton a[id*="_search"]').addClass('btn btn-sm btn-purple').find('.ui-icon').attr('class', 'icon-search');
							}
							
							function beforeDeleteCallback(e) {
								var form = $(e[0]);
								if(form.data('styled')) return false;
								
								form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
								style_delete_form(form);
								
								form.data('styled', true);
							}
							
							function beforeEditCallback(e) {
								var form = $(e[0]);
								form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
								style_edit_form(form);
							}
						
						
						
							//it causes some flicker when reloading or navigating grid
							//it may be possible to have some custom formatter to do this as the grid is being created to prevent this
							//or go back to default browser checkbox styles for the grid
							function styleCheckbox(table) {
							/**
								$(table).find('input:checkbox').addClass('ace')
								.wrap('<label />')
								.after('<span class="lbl align-top" />')
						
						
								$('.ui-jqgrid-labels th[id*="_cb"]:first-child')
								.find('input.cbox[type=checkbox]').addClass('ace')
								.wrap('<label />').after('<span class="lbl align-top" />');
							*/
							}
							
						
							//unlike navButtons icons, action icons in rows seem to be hard-coded
							//you can change them like this in here if you want
							function updateActionIcons(table) {
								/**
								var replacement = 
								{
									'ui-icon-pencil' : 'icon-pencil blue',
									'ui-icon-trash' : 'icon-trash red',
									'ui-icon-disk' : 'icon-ok green',
									'ui-icon-cancel' : 'icon-remove red'
								};
								$(table).find('.ui-pg-div span.ui-icon').each(function(){
									var icon = $(this);
									var $class = $.trim(icon.attr('class').replace('ui-icon', ''));
									if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
								})
								*/
							}
							
							//replace icons with FontAwesome icons like above
							function updatePagerIcons(table) {
								var replacement = 
								{
									'ui-icon-seek-first' : 'icon-double-angle-left bigger-140',
									'ui-icon-seek-prev' : 'icon-angle-left bigger-140',
									'ui-icon-seek-next' : 'icon-angle-right bigger-140',
									'ui-icon-seek-end' : 'icon-double-angle-right bigger-140'
								};
								$('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function(){
									var icon = $(this);
									var $class = $.trim(icon.attr('class').replace('ui-icon', ''));
									
									if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
								})
							}
						
							function enableTooltips(table) {
								$('.navtable .ui-pg-button').tooltip({container:'body'});
								$(table).find('.ui-pg-div').tooltip({container:'body'});
							}
						
							//var selr = jQuery(grid_selector).jqGrid('getGridParam','selrow');
						
						
						});
				}
			}
		});
			
			
			
		</script>
	
</body>
</html>
